﻿using Jet.Payment.Cielo.Model;
using System;
using System.Collections.Generic;
using System.Text;
using System.Xml.Serialization;

namespace Jet.Payment.Cielo.Response
{
    [XmlRoot("transacao")]
    public class TransactionResponse
    {
        [XmlAttribute("versao")]
        public string Version { get; set; }

        [XmlAttribute("id")]
        public string Id { get; set; }

        [XmlElement("url-autenticacao")]
        public string Url { get; set; }

        [XmlElement("tid")]
        public string TransactionId { get; set; }

        [XmlElement("status")]
        public string StatusString { get; set; }

        public StatusTransaction Status
        {
            get
            {
                int intCast;
                return int.TryParse(StatusString, out intCast) ? (StatusTransaction)intCast : default(StatusTransaction);
            }
            set
            {
                StatusString = ((int)value).ToString();
            }
        }

        [XmlElement("dados-pedido")]
        public Order Order { get; set; }

        [XmlElement("forma-pagamento")]
        public PaymentType PaymentType { get; set; }

        [XmlElement("autorizacao")]
        public Autorization Autorization { get; set; }

        [XmlElement("captura")]
        public Capture Capture { get; set; }
    }
}
